package main

import (
	"fmt"
	"io/ioutil"

	"stock_ths/config"
	"stock_ths/hq"
	"stock_ths/server"

	"github.com/robertkrimen/otto"
)

func GetOneData(code, cook string) {
	d, err := hq.GetTime(code, cook)
	if err != nil {
		fmt.Printf("GetTime error:%v\n", err)
		return
	}

	fmt.Printf("code=%v, timeDot:%s, nowPrice:%s\n", d.Code, d.TimeDot[0][0], d.TimeDot[0][1])
}

// func GetDaysData(code, cook string) {
// 	ds, err := hq.GetDays(code, cook)
// 	if err != nil {
// 		fmt.Println("GetDays error:", err)
// 		return
// 	}

// 	fmt.Println("code:", code, "ds len=", len(ds))
// }
func main() {

	jsfile := "aes.min.js"
	bytes, err := ioutil.ReadFile(jsfile)
	if err != nil {
		fmt.Println("ReadFile:", err)
		return
	}
	vm := otto.New()
	_, err = vm.Run(string(bytes))
	if err != nil {
		fmt.Println("Run:", err)
		return
	}

	config.LoadConfig("config/config.json")

	server.InitHttpServer()
}
